//
//  ChannelButton.m
//  U9WatchGame
//
//  Created by uuu9 on 15/10/27.
//  Copyright © 2015年 Jason. All rights reserved.
//

#import "ChannelButton.h"

@implementation ChannelButton

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        // 设置按钮文字居中
       // self.titleLabel.textAlignment = NSTextAlignmentCenter;
        // 让图片按照原来的宽高比显示出来
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        self.titleLabel.textAlignment = NSTextAlignmentRight;
    }
    return self;
}

#pragma mark 控制UIImageView的位置和尺寸
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imageX = 5;
    CGFloat imageY = 0;
    CGFloat imageWidth = 15;
    CGFloat imageHeight = contentRect.size.height;
    return CGRectMake(imageX, imageY, imageWidth, imageHeight);
}

#pragma mark 控制UILabel的位置和尺寸
// contentRect其实就是按钮的位置和尺寸
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat titleX = 25;
    CGFloat titleY = 0;
    CGFloat titleWidth = contentRect.size.width - 30;
    CGFloat titleHeight = contentRect.size.height;
    
    return CGRectMake(titleX, titleY, titleWidth, titleHeight);
}

@end
